package com.taofuxn.yycreazy.ui.activity;

import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.taofuxn.yycreazy.R;
import com.taofuxn.yycreazy.ui.base.ToobarActivity;
import com.taofuxn.yycreazy.ui.view.ZoomImageView;

import butterknife.InjectView;

/**
 * 图片展示
 * Created by wanghuafu on 16/9/17.
 */
public class DisplayImgActivity extends ToobarActivity {
    private String imgUrl;
    @InjectView(R.id.displayImg)
    ZoomImageView displayImg;

    @Override
    protected int setContentLayout() {
        return R.layout.activity_display_img;
    }

    @Override
    protected void init() {
        imgUrl = getIntent().getStringExtra("url");
        if (!TextUtils.isEmpty(imgUrl)) {
            Glide.with(this).load(imgUrl).priority(Priority.priority).diskCacheStrategy(DiskCacheStrategy.SOURCE).into(displayImg);
        }
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_displayimage_menu,menu);
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()){
            case R.id.downloadImage:
                //下载图片，并保存到相册
                break;
        }
        return super.onOptionsItemSelected(item);
    }
}
